"use strict";

const expect = require("chai").expect;
const path = require("path");
const request = require("supertest");

const Router = require(path.join("..", "..", "..", "app", "routers", "router"));
const app = require(path.join("..", "..", "..", "fixtures", "server"));

describe("routers/Router", function() {
  let subject = new Router("pet");
  it("#initialize", function() {
    expect(subject).to.be.instanceof(Router);
  });
  it("#constructor", function() {
    expect(subject.uri).to.be.ok;
  });
  describe("Router/request", function() {
    before(function() {
      request(app)
        .get("/")
        .expect(200);
    });
    it("#requestAll", function(done) {
      subject.requestAll()
        .then(function(payload) {
          expect(payload).to.be.an("Array");
          expect(payload[0]).to.have.keys("id",
                                          "name");
          done();
        });
    });
    it("#requestOne", function(done) {
      subject.requestOne(1)
        .then(function(payload) {
          expect(payload).to.have.keys("id",
                                       "name");
          done();
        });
    });
  });
});
